##############################
# Table A1
##############################

rm(list=ls())

#sink("~/Dropbox/COVID Peru/08_replication/01_descriptive.txt")

library(foreign)
library(Hmisc)
library(ri)
library(stargazer)

##############################
# Prepare data
##############################

# load data
d = read.dta("clean_survey_experiment_covid_peru.dta")

# explore data
names(d)

##########################
# Descriptive statistics
##########################

d2 = data.frame(d$age_cat,
                d$education,
                d$female,
                d$rural,
                d$lima,
                d$trabajador_dependiente,
                d$trabajador_nodependiente,
                d$student,
                d$retired,
                d$homemaker,
                d$notworking)

colnames(d2) = c("Age",
                 "Education",
                 "Female",
                 "Rural",
                 "Capital city",
                 "Dependent worker",
                 "Independent worker",
                 "Student",
                 "Retired",
                 "Homemaker",
                 "Not working")
colnames(d2)

stargazer(d2,
          type = "text",
          colnames = FALSE,
          min.max = FALSE,
          title="", 
          summary.stat = c("mean","sd","min","max","n"),
          digits=3, 
          rownames=FALSE, 
          align=TRUE, 
          float = TRUE, 
          float.env = "table", 
          table.placement = "H",
          header = FALSE, 
          no.space = TRUE)

sink()
